package com.superman.supermarket.client.composite.categories.third;

import java.util.Map;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.superman.mvpframe.client.widget.lazy.LazyImage;
import com.superman.supermarket.client.composite.IUIModule;
import com.superman.supermarket.client.utils.ActivityJumpUrl;

/**
 * 分类三级
 * 
 * @author superman
 * @version 2016年5月4日上午10:39:37
 */
public class ThirdModule extends Composite implements IUIModule {

	interface ThirdModuleUiBinder extends UiBinder<Widget, ThirdModule> {
	}

	private static ThirdModuleUiBinder uiBinder = GWT.create(ThirdModuleUiBinder.class);

	private String cataName;
	private String cateId;
	@UiField
	LazyImage img;

	@UiField
	FlowPanel mainpanel;
	@UiField
	HTML namehtml;

	/**
	 * 构造方法
	 * 
	 * @author superman
	 * @version 2018年8月14日 下午4:45:54
	 */
	public ThirdModule() {
		initWidget(uiBinder.createAndBindUi(this));
		mainpanel.addDomHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				ActivityJumpUrl.pushToCategorySkuListPage(cateId, cataName);
			}
		}, ClickEvent.getType());
	}

	@Override
	public Map<String, Object> getData() {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * @author superman
	 * @version 2018年8月14日 下午10:16:41
	 * @param jo
	 */
	public void setData(JSONObject jo) {
		cateId = jo.get("CATALOG_ID").isString().stringValue();
		cataName = jo.get("CATALOG_NAME").isString().stringValue();
		if (jo.get("CATALOG_ICON") != null)
			img.setUrl(jo.get("CATALOG_ICON").isString().stringValue());
		namehtml.setText(cataName);
	}

	@Override
	public void setData(Map<String, Object> map) {
	}
}
